package com.hsp.Demo_03_object;

public class Demo_15 {
    public static void main(String[] args) {
        /*
         4、编写类A03，实现数组的赋值功能，copyArr,输入旧数组，返回一个新数组，元素和旧数组一样。
         注意： 必须要是一个新数组
         */
        int[] arr01 = {1, 2, 3, 4, 5, 9 , 10};
        A03 a03 = new A03();
        int[] arr02 = a03.copyArr(arr01);

        System.out.println("===========arr01==========");
        for(int i = 0; i < arr01.length; i++){
            System.out.print(arr01[i] + " ");
        }
        System.out.println();
        System.out.println("===========arr02==========");
        for(int i = 0; i < arr02.length; i++){
            System.out.print(arr02[i] + " ");
        }
        System.out.println();

        System.out.println("===========修改后的arr01==========");
        arr01[0] = 100;
        for(int i = 0; i < arr01.length; i++){
            System.out.print(arr01[i] + " ");
        }
        System.out.println();

        System.out.println("===========未修改后的arr02==========");
        for(int i = 0; i < arr02.length; i++){
            System.out.print(arr02[i] + " ");
        }


    }
}

class A03{
    public int[] copyArr(int[] arr01){
        int[] arr02 = new int[arr01.length];
        for(int i = 0; i < arr01.length; i++){
            arr02[i] = arr01[i];
        }
        return arr02;
    }
}
